import java.util.Scanner;

public class Text1 {
   /* public static int max2(int x, int y) {
        if (x > y) {
            return x;
        } else {
            return y;
        }
    }

    public static int max3(int ss, int yx, int xy) {
        int max = max2(max2(ss, yx), xy);
        return max;
    }

    *//*public static int max3(int x, int y, int xy) {
        int max = 0;
        while (true) {
            max = x;
            if(max > y && max > xy) {
                return max;
            } else if (max < y || max < xy) {
                if (y > xy) {
                    return y;
                }else {
                    return xy;
                }
            }

        }
    }*//*
    public static void main(String[] args) {
        int aa = nse(5);
        System.out.println("n的阶乘是：" + aa);
      int mun = 0;
        for (int i = 0; i < 6; i++) {

        }

    }

    public static void main1(String[] args) {
        //在max3这个函数中，调用max2函数，来实现3个数的最大值计算
        //创建方法求两个数的最大值max2，随后再写一个求3个数的最大值的函数max3。

        max2(12, 23);
        int max = max2(12, 23);
        System.out.println("两个数比较大的是：" + max);
        max3(10, 20, 30);
        int Max = max3(10, 20, 30);
        System.out.println();
    }

    public static int nse(int n) {
        if (n == 1) {
            return 1;
        } else {
            return n * nse(n - 1);
        }
    }*/
   public static void main1(String[] args) {
       Scanner s = new Scanner(System.in);
       int n = s.nextInt();
       System.out.println("阶乘之和是：" + fac(n));
   }
   public static int fac(int n) {
       int mun = 0;
       int fa = 1;
       for (int i = 1; i <= n; i++) {
           fa = fa * i;
           mun += fa;
       }
       return mun;
   }

    public static void main2(String[] args) {
        int dd = fei(40);
        System.out.println("第N个斐波那契数列是：" + dd);
    }
    public static int fei(int x) {
       int aa = 1;
       int bb = 1;
       int cc = 0;
        for (int i = 3; i <=x ; i++) {
            cc = aa + bb;
            bb = aa;
            aa = cc;
        }
        return cc;
    }

    public static void main3(String[] args) {
       int dd = scd(15,32);
        System.out.println("两个整数的和：" + dd);
        double ff = scd(12,32,4);
        System.out.println("三个小数的和：" + ff);
    }
    public static int scd(int x, int y) {
       return x + y;
    }
    public static double scd(double x , double y ,double xy) {
       return x + y + xy;
    }
    public static int saa(int x , int y) {
       return x>y?x:y;
    }
    public static double saa(double x ,double y ,double xy) {
       double ss = x>y?x:y;
       if (ss < xy) {
           return xy;
       }else {
           return ss;
       }
    }

    public static void main4(String[] args) {
        int ww = saa(15,32);
        System.out.println("两个整数的最大值：" + ww);
        double ee = saa(21,44,32);
        System.out.println("三个数的最大值：" + ee);
    }
    public static int digui(int x) {
       if (x == 1)
           return 1;
       else {
           return x * digui(x-1);
       }
    }

    public static void main5(String[] args) {
        int gg = digui(5);
        System.out.println("x的阶乘是：" + gg);
    }
    public static void mo(char po1, char po2) {
        System.out.println(po1 + "->" + po2 + " ");
    }
    public static void han(int n ,char po1 , char po2 ,char po3) {
       if(n == 1) {
           mo(po1 , po2);
       }else {
           han(n - 1, po1 , po3 , po2);
           mo(po1 , po3);
           han(n-1 ,po2 , po1 , po3);
       }
    }

    public static void main(String[] args) {
        han(1 , 'a' , 'b' , 'c');
        System.out.println();
        han(2, 'a' , 'b' , 'c');
        System.out.println();
        han(3, 'a' , 'b' , 'c');
        System.out.println();
    }
}
